package priv.yiyuan.example.design.pay;

import java.util.HashMap;
import java.util.Map;

/**
 * 微信支付类
 * <p>
 * 抽象子类
 */
public class WeChatPayment extends Payment {

    private String openId;

    public WeChatPayment(PaymentProcessor paymentProcessor, String openId) {
        super(paymentProcessor);
        this.openId = openId;
    }

    @Override
    public boolean makePayment(double amount) {

        Map<String, String> details = new HashMap<>();
        details.put("openId", openId);
        return paymentProcessor.processPayment(amount, details);

    }

    @Override
    public boolean requestRefund(double amount) {
        System.out.println("注意: 微信旧版支付只能取消支付，不能部分退款");
        return paymentProcessor.refund(amount, getTransactionId());
    }
}
